﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.IO;

namespace DotNetNuke.Modules.ActiveSocialMigrator.Utilities
{
    public class Text
    {
        static internal string InsertLineBreaks(string s)
        {
            return InsertLineBreaks(s, 20);
        }
        static internal string InsertLineBreaks(string s, int MaxBlankLines)
        {
            StringBuilder sb = new StringBuilder();
            int linecount = 0;
            using (StringReader sr = new StringReader(s))
            {
                while (sr.Peek() >= 0)
                {
                    string l = sr.ReadLine();
                    if (l.Length == 0)
                    {
                        linecount += 1;
                    } else
                    {
                        linecount = 0;
                    }
                    if (linecount < MaxBlankLines)
                    {
                        sb.Append(l + "<br />");
                    } else
                    {
                        sb.Append(l);
                    }

                }
            }
            return sb.ToString();
        }
    }
}